package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class PreParedStmt3 {
	public static void main(String[] args) {

		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
			Connection con = DriverManager.getConnection(
					"jdbc:oracle:thin:@10.23.245:1521:orcl", "scott", "tiger");
			System.out.println("Driver Connected successfully.");

			PreparedStatement pstmt = con
					.prepareStatement("SELECT * FROM myTable");

			ResultSet rs = pstmt.executeQuery();
			while (rs.next()) {
				System.out.println("SrNo=" + rs.getInt(1));
				System.out.println("SrNo=" + rs.getString("Name"));
				System.out.println("SrNo=" + rs.getFloat(3));
			}
			pstmt.close();
			con.close();

		} catch (Exception e) {
			System.out.println(e.toString());
		}
	}
}
